/**
 * 机构分类角色功能管理初始化
 */
var OrgcategoryRoleFunction = {
    id: "OrgcategoryRoleFunctionTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
OrgcategoryRoleFunction.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
            {title: '编号', field: 'sofId', visible: true, align: 'center', valign: 'middle'},
            {title: '功能编号', field: 'sfId', visible: true, align: 'center', valign: 'middle'},
            {title: '功能名称', field: 'sfName', visible: true, align: 'center', valign: 'middle'},
            {title: '父功能', field: 'sfPid', visible: true, align: 'center', valign: 'middle'},
            {title: '功能地址', field: 'sfUrl', visible: true, align: 'center', valign: 'middle'},
            {title: '功能图标', field: 'sfIcon', visible: true, align: 'center', valign: 'middle'},
            {title: '功能状态', field: 'sfState', visible: true, align: 'center', valign: 'middle'},
            {title: '操作权限', field: 'spMethod', visible: true, align: 'center', valign: 'middle'},
            {title: '机构分类角色ID', field: 'sorId', visible: true, align: 'center', valign: 'middle'},
            {title: '创建人', field: 'createUser', visible: true, align: 'center', valign: 'middle'},
            {title: '创建时间', field: 'createTime', visible: true, align: 'center', valign: 'middle'},
            {title: '修改人', field: 'updateUser', visible: true, align: 'center', valign: 'middle'},
            {title: '修改时间', field: 'updateTime', visible: true, align: 'center', valign: 'middle'}
    ];
};

/**
 * 检查是否选中
 */
OrgcategoryRoleFunction.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录！");
        return false;
    }else{
        OrgcategoryRoleFunction.seItem = selected[0];
        return true;
    }
};

/**
 * 点击添加机构分类角色功能
 */
OrgcategoryRoleFunction.openAddOrgcategoryRoleFunction = function () {
    var index = layer.open({
        type: 2,
        title: '添加机构分类角色功能',
        area: ['800px', '420px'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/orgcategoryRoleFunction/orgcategoryRoleFunction_add'
    });
    this.layerIndex = index;
};

/**
 * 打开查看机构分类角色功能详情
 */
OrgcategoryRoleFunction.openOrgcategoryRoleFunctionDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '机构分类角色功能详情',
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/orgcategoryRoleFunction/orgcategoryRoleFunction_update/' + OrgcategoryRoleFunction.seItem.id
        });
        this.layerIndex = index;
    }
};

/**
 * 删除机构分类角色功能
 */
OrgcategoryRoleFunction.delete = function () {
    if (this.check()) {
        var ajax = new $ax(Feng.ctxPath + "/orgcategoryRoleFunction/delete", function (data) {
            Feng.success("删除成功!");
            OrgcategoryRoleFunction.table.refresh();
        }, function (data) {
            Feng.error("删除失败!" + data.responseJSON.message + "!");
        });
        ajax.set("orgcategoryRoleFunctionId",this.seItem.id);
        ajax.start();
    }
};

/**
 * 查询机构分类角色功能列表
 */
OrgcategoryRoleFunction.search = function () {
    var queryData = {};
    queryData['condition'] = $("#condition").val();
    OrgcategoryRoleFunction.table.refresh({query: queryData});
};

$(function () {
    var defaultColunms = OrgcategoryRoleFunction.initColumn();
    var table = new BSTable(OrgcategoryRoleFunction.id, "/orgcategoryRoleFunction/list", defaultColunms);
    table.setPaginationType("client");
    OrgcategoryRoleFunction.table = table.init();
});
